<template>
  <div>
    <el-menu class="el-menu-demo" mode="horizontal">
      <el-menu-item index="1">11111</el-menu-item>
      <el-menu-item index="2">社员管理</el-menu-item>
      <el-menu-item index="3">管理</el-menu-item>
      <el-menu-item index="4">财务管理</el-menu-item>
      <el-menu-item index="5">勤怠管理</el-menu-item>
      <el-menu-item index="6">募集管理</el-menu-item>
      <el-menu-item index="7">购买管理</el-menu-item>
      <el-menu-item index="8">帐票管理</el-menu-item>
    </el-menu>

    <el-row class="tac">
      <el-col :span="4">
        <el-menu default-active="2" class="el-menu-vertical-demo">
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">社员管理</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">权限管理</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">管理</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-input
        v-model="inputCode"
        placeholder="请输入要删除的Code"
        style="width: 30%"
      ></el-input>
      <el-input
        v-model="inputName"
        placeholder="请输入要删除的Name"
        style="width: 30%"
      ></el-input>
      <el-button type="primary" @click="get">搜索</el-button>
      <el-table :data="tableData" style="width: 70%">
        <el-table-column
          prop="authorityCode"
          label="号码"
          width="180"
        ></el-table-column>
        <el-table-column prop="authorityName" label="姓名" width="180">
        </el-table-column>
        <el-table-column label="操作"
          ><el-button type="danger" @click="del"
            >削除</el-button
          ><el-button type="danger" @click="detail"
            >详情</el-button
          ></el-table-column
        >
      </el-table>
    </el-row>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'FormTimePicker',
  data() {
    return {
      auCode: '',
      tableData: [],
      authorityCode: '',
      inputCode: '',
      inputName: '',
      flag: 0
    }
  },
  methods: {
    get() {
      axios
        .post('http://127.0.0.1:8089/bff/authority/info', {
          authorityCode: this.inputCode,
          authorityName: this.inputName
        })
        .then((response) => {
          this.tableData = [response.data.resultDto]
          this.authorityCode = response.data.resultDto.authorityCode
          if (this.authorityCode == null && this.flag > 0) {
            alert('查询不到数据,请重新输入')
          }
          this.flag++
        })
        .catch((error) => {
          console.log(error)
        })
    },
    del() {
      axios
        .delete(
          'http://127.0.0.1:8089/bff/authority/delete?authorityCode=' +
            this.authorityCode +
            '&deletionFlag=true'
        )
        .then((res) => {
          // eslint-disable-next-line eqeqeq
          if (res.data.resultDto.processingResult == 1) {
            alert('削除に成功しました')
            location.reload()
          } else {
            alert('削除に失敗しました')
          }
        })
        .catch((error) => {
          alert(error)
        })
    },
    detail() {

    }
  },
  created() {
    this.get()
  }
}
</script>
